/**
 * 
 */
package com.thor.palmmall.rest.chart.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.rest.common.APicture;
import com.thor.palmmall.spi.chart.SPicture;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class APictureConverter implements Converter<SPicture, APicture> {

  public static APictureConverter getInstance() {
    if (instance == null)
      instance = new APictureConverter();
    return instance;
  }

  private static APictureConverter instance;

  private APictureConverter() {
  }

  @Override
  public APicture convert(SPicture source) {
    if (source == null) {
      return null;
    }
    APicture target = new APicture();
    target.setCaption(source.getCaption());
    target.setId(source.getId());
    if (source.getName() != null) {
      target.setName(source.getName());
    }
    return target;
  }

}
